package com.mew.common.enm;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 1是安卓，2是苹果，3是Window，4是模拟器,5是无法识别
 */
public enum DeviceType {
    Android(1),
    IPhone(2),
    Windows(3),
    Simulator(4)
    ;

    private final static Map<Integer, DeviceType> stateMap
            = Arrays.stream(DeviceType.values()).collect(Collectors.toMap(DeviceType::code, code -> code));

    private final int code;

    /**
     * @param code 代码
     */
    DeviceType(final int code) {
        this.code = code;
    }

    public int code() {
        return this.code;
    }

    /**
     * @param code 代码
     * @return 转换出来的状态码
     */
    public static DeviceType parse(int code) {
        return stateMap.get(code);
    }


}
